#ifndef __XKK_THREADPOOL_H__
#define __XKK_THREADPOOL_H__

#include "TaskQueue.hpp"

#include <vector>
#include <memory>
#include <functional>

using namespace std;
namespace xkk
{
class Thread;

using Task=function<void()>;
class ThreadPool
{
public:
    ThreadPool(size_t threadNum,size_t queSize);
    ~ThreadPool();

    void start();
    void stop();
    void addTask(Task &&task);
private:
    Task getTask();
    void threadFunc();
private:
    size_t _threadNum;
    size_t _queSize;
    vector<unique_ptr<Thread>> _threads;
    TaskQueue _taskQue;
    bool _isExit;
    
};

}//end of namespace xkk
#endif
